/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.TX.tta;

import Helper.Helper_Survey;
import entity.Places;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import session.TX.SurveyBeanRemote;

@ManagedBean(name = "surveyMB")
@SessionScoped
public class SurveyMB {

    @EJB
    SurveyBeanRemote sBean;
//    @ManagedProperty(value = "#{fakeMainPortalMB}")
//    private FakeMainPortalMB portalManagedBean;
    private Integer month;
    private Integer year;
    private Long outletId;
    private List<Double> resultList = new ArrayList<Double>();
    List<Helper_Survey> results = new ArrayList<Helper_Survey>();
  

    /** Creates a new instance of OMPIPMB */
    public SurveyMB() {
    }
    
    
    public Double getOutletAmbienceResult (long outletid, int month, int year) {
    Places place = sBean.getSpecificPlace(outletid);
    double result = sBean.getAmbienceResult(place, month, year);
    return result;
    }
    
    public Double getAmbienceResult (int month, int year) {
    Places place = sBean.getAllPlaces();
    double result = sBean.getAmbienceResult(place, month, year);
    return result;
    }
    
    public Double getOutletServiceResult (long outletid, int month, int year) {
    Places place = sBean.getSpecificPlace(outletid);
    double result = sBean.getServiceResult(place, month, year);
    System.out.println("TEST" + result);
    return result;
    }
    
    public Double getServiceResult (int month, int year) {
    Places place = sBean.getAllPlaces();
    double result = sBean.getServiceResult(place, month, year);
    return result;
    }
    
    public Double getOutletFoodResult (long outletid, int month, int year) {
    Places place = sBean.getSpecificPlace(outletid);
    double result = sBean.getFoodResult(place, month, year);
    return result;
    }
    
    public Double getFoodResult (int month, int year) {
    Places place = sBean.getAllPlaces();
    double result = sBean.getFoodResult(place, month, year);
    return result;
    }
    
    public Double getOutletPriceResult (long outletid, int month, int year) {
    Places place = sBean.getSpecificPlace(outletid);
    double result = sBean.getPricingResult(place, month, year);
    return result;
    }
    
    public Double getPriceResult (int month, int year) {
    Places place = sBean.getAllPlaces();
    double result = sBean.getPricingResult(place, month, year);
    return result;
    }
    
    public int getNoOfReviews(long outletid, int month, int year) {
    Places place = sBean.getSpecificPlace(outletid);
    int result = sBean.getNoOfReviews(place, month, year);
    return result;
    }

    public List<Helper_Survey> getResults() {
        return results;
    }

    public void setResults(List<Helper_Survey> results) {
        this.results = results;
    }
    
    public List<Helper_Survey> getResult() {
        List<Helper_Survey> output = new ArrayList<Helper_Survey>();
        Integer month = Integer.valueOf(getMonth());
        Integer year = Integer.valueOf(getYear());
        Long outletId = Long.valueOf(getOutletId());
        Double oaResult = getAmbienceResult(month, year);
        Double aResult = getOutletAmbienceResult(outletId, month, year);
        Helper_Survey temp = new Helper_Survey("Ambience", aResult, oaResult);
        output.add(temp);
        Double foodResult = getOutletFoodResult(outletId, month, year);
        Double overallFoodResult = getFoodResult(month, year);
        Helper_Survey temp1 = new Helper_Survey("Food", foodResult, overallFoodResult);
        output.add(temp1);
        Double priceResult = getOutletPriceResult(outletId, month, year);
        Double overallPriceResult = getPriceResult(month, year);
        Helper_Survey temp2 = new Helper_Survey("Price", priceResult, overallPriceResult);
        output.add(temp2);
        Double serviceResult = getOutletServiceResult(outletId, month, year);
        Double overallServiceResult = getServiceResult(month, year);
        Helper_Survey temp3 = new Helper_Survey("Service", serviceResult, overallServiceResult);
        output.add(temp3);
        return output;
    }

 
    /**
     * @return the year
     */
    public Integer getYear() {
        return year;
    }

    /**
     * @param year the year to set
     */
    public void setYear(Integer year) {
        this.year = year;
    }

    /**
     * @return the resultList
     */
    public List<Double> getResultList() {
        return resultList;
    }

    /**
     * @param resultList the resultList to set
     */
    public void setResultList(List<Double> resultList) {
        this.resultList = resultList;
    }

    /**
     * @return the outletId
     */
    public Long getOutletId() {
        return outletId;
    }

    /**
     * @param outletId the outletId to set
     */
    public void setOutletId(Long outletId) {
        this.outletId = outletId;
    }

    /**
     * @return the month
     */
    public Integer getMonth() {
        return month;
    }

    /**
     * @param month the month to set
     */
    public void setMonth(Integer month) {
        this.month = month;
    }

}
